//
//  ImageMode.m
//  DogeLegs
//
//  Created by 宋华 on 2017/8/21.
//  Copyright © 2017年 宋华. All rights reserved.
//

#import "ImageMode.h"

@implementation ImageMode

+ (NSMutableArray *)testNetImgs {
    NSMutableArray *netArrs = [NSMutableArray array];
    
//    NSArray *whs = @[@{@"w":@550,@"h":@362}];
//    NSArray *ImgUrls = @[@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503305115513&di=05b309b068e32d10855990954d8d8e0b&imgtype=0&src=http%3A%2F%2Fy2.ifengimg.com%2Fa282fca64216bddb%2F2013%2F0927%2Fre_5244d39b0d5db.jpg"];
//    NSArray *whs = @[@{@"w":@700,@"h":@1050}];
//    NSArray *ImgUrls = @[@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503305115514&di=14242d46af37ccf850c28ec7e0659a38&imgtype=0&src=http%3A%2F%2Fimg4.duitang.com%2Fuploads%2Fblog%2F201401%2F06%2F20140106161046_vvZWz.thumb.700_0.jpeg"];
//    NSArray *whs = @[@{@"w":@1024,@"h":@1024}];
//    NSArray *ImgUrls = @[@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503305143510&di=c15e57c0e315a2b847a1d3dee0835c2a&imgtype=jpg&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fe7cd7b899e510fb3b993648ad333c895d1430c20.jpg"];
    
    NSArray *whs = @[@{@"w":@400,@"h":@300},@{@"w":@700,@"h":@1050},@{@"w":@1024,@"h":@1024},@{@"w":@550,@"h":@362}];
    NSArray *ImgUrls = @[@"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3467076331,4034849124&fm=11&gp=0.jpg"
      ,@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503305115514&di=14242d46af37ccf850c28ec7e0659a38&imgtype=0&src=http%3A%2F%2Fimg4.duitang.com%2Fuploads%2Fblog%2F201401%2F06%2F20140106161046_vvZWz.thumb.700_0.jpeg",
      @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503305143510&di=c15e57c0e315a2b847a1d3dee0835c2a&imgtype=jpg&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fe7cd7b899e510fb3b993648ad333c895d1430c20.jpg",
      @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503305115513&di=05b309b068e32d10855990954d8d8e0b&imgtype=0&src=http%3A%2F%2Fy2.ifengimg.com%2Fa282fca64216bddb%2F2013%2F0927%2Fre_5244d39b0d5db.jpg"];
    for (NSInteger i = 0; i < ImgUrls.count; i++) {
        ImageMode *mode = [[ImageMode alloc] init];
        mode.sourceType =ImageSourceType_net;
        mode.imageUrl =ImgUrls[i];
        mode.imageWidth = [[whs[i]objectForKey:@"w"] floatValue];
        mode.imageHeight = [[whs[i]objectForKey:@"h"] floatValue];
        [netArrs addObject:mode];
    }

    return netArrs;
}

+ (ImageMode *)localImageMode:(UIImage *)image {
    ImageMode *mode = [[ImageMode alloc] init];
    mode.sourceType =ImageSourceType_local;
    mode.localImg = image;
    mode.imageWidth = image.size.width;
    mode.imageHeight = image.size.height;
    return mode;
}

- (CGFloat)scaleHeightToNotDetailWidth {
//    w/h = iw/ih
//h  = w *ih／iw
    CGFloat height = self.imageHeight/self.imageWidth * kContentMaxWidth;
    return height;
}

@end
